<?php 
	require('funkcije.php');
	require('validacija.php');
?>
<form id="menu_templates_form" action="" method="post" enctype="multipart/form-data">
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed; background: #FFFFFF; padding-top:10px; padding-left:10px; padding-right:10px; ">
	<tr>
		<td class="admin_cell" width="150">Selected Menu Template:</td>
		<td class="admin_cell">
			<select name="content_type" onChange="document.location.href='?selected='+this.value" style="width:300">
				<option value="" selected>None</option>
				<?php 
					$result = mysql_query("SELECT * FROM ".DB_PERFIX."menu_templates ORDER BY template_id ASC;");
					while($row = mysql_fetch_array($result))
					{
						if ($row['id'] == $_GET['selected'])
						{
							echo '<option value="'.$row['id'].'" selected>'.$row['name'].' Level('.$row['level'].')</option>';
						}
						else
						{
							echo '<option value="'.$row['id'].'">'.$row['name'].' Level('.$row['level'].')</option>';
						}
					}
				?>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"></td>
	</tr>
	<tr>
		<td class="admin_cell">Name:</td>
		<td class="admin_cell">
			<input name="name" type="text" value="<?php echo $item['name']; ?>" style="width:300">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<?php echo $NameStatus; ?>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<tr>
		<td class="admin_cell">Type:</td>
		<td class="admin_cell">
			<select name="menu_type"  style="width:300px;" onChange="document.location.href='?selected=<?php echo $item['id']; ?>&type='+this.value">
				<option value="0" <?php if ($item['type'] == 0){echo 'selected'; }?>>Top Menu Standard</option>
				<option value="1" <?php if ($item['type'] == 1){echo 'selected'; }?>>Side Menu Standard</option>
				<option value="2" <?php if ($item['type'] == 2){echo 'selected'; }?>>Top Menu Fixed</option>
			</select>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<tr>
		<td class="admin_cell">Level: </td>
		<td class="admin_cell">
			<select name="content_type" onChange="document.location.href='?selected='+this.value" style="width:300">
				<?php 
					$result = mysql_query('SELECT * FROM '.DB_PERFIX.'menu_templates WHERE template_id='.$item['template_id'].';');
					while($row = mysql_fetch_array($result))
					{
						if ($row['level'] == $item['level'])
						{
							echo '<option value="'.$row['id'].'" selected>'.$row['name'].' Level('.$row['level'].')</option>';
						}
						else
						{
							echo '<option value="'.$row['id'].'">'.$row['name'].' Level('.$row['level'].')</option>';
						}
					}
				?>
			</select>
			<?php if (($item['id'] > 0) && ($item['level'] < $item['max_levels']) && !($item['child_id'] > 0)): ?>
				<button name="add_level" value="<?php echo $item['template_id']; ?>" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" class="buttons">Add new level</button>
			<?php endif; ?>
		</td>
		<td class="admin_cell_stat"><?php echo $levStatus ?></td>
	</tr>
	<tr>
		<td class="admin_cell">Height:</td>
		<td class="admin_cell">
			<select name="height" style="width:100px;">
				<?php 
					$i=1;
					while($i <= 200)
					{
						if ($i == $item['height'])
						{
							echo '<option value="'.$i.'" selected>'.$i.'</option>';
						}
						else
						{
							echo '<option value="'.$i.'">'.$i.'</option>';
						}
						$i ++;
					}
				?>
			</select> px
		</td>
		<td class="admin_cell_stat"><?php echo $heightStatus ?></td>
	</tr>
	<tr>
		<td class="admin_cell">Content Alignement:</td>
		<td class="admin_cell">
			<select name="valign" style="width:100px;">
				<option value="">Vertical</option>
				<option value=" vertical-align: top; ">Top</option>
				<option value=" vertical-align: middle; ">Middle</option>
				<option value=" vertical-align: bottom; ">Bottom</option>
			</select>&nbsp;&nbsp;
			<select name="align" style="width:100px;">
				<option value="">Horisontal</option>
				<option value=" text-align: left; ">Left</option>
				<option value=" text-align: center; ">Center</option>
				<option value=" text-align: right; ">Right</option>
			</select>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<tr>
		<td class="admin_cell">Left/Top Image:</td>
		<td class="admin_cell">
			<input id="image_l" name="image_l" type="file" ></input>
			<?php 
				if($item['image_l'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image_l']); 
					$fp = fopen(MENU_PATH.$item['image_l'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				}
				echo $lImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image_l'] != "") { ?>
				<input type="checkbox" name="delete_l" value="1"><strong>(Delete Left)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Right/Bottom Image:</td>
		<td class="admin_cell">
			<input id="image_r" name="image_r" type="file" value=""></input>
			<?php 
				if($item['image_r'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image_r']); 
					$fp = fopen(MENU_PATH.$item['image_r'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				} 
				echo $rImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image_r'] != "") { ?>
				<input type="checkbox" name="delete_r" value="1"><strong>(Delete Right)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Background Image:</td>
		<td class="admin_cell">
			<input id="image_bg" name="image_bg" type="file" value=""></input>
			<?php 
				if($item['image_bg'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image_bg']); 
					$fp = fopen(MENU_PATH.$item['image_bg'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				}
				echo $bgImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image_bg'] != "") { ?>
					<input type="checkbox" name="delete_bg" value="1"><strong>(Delete Background)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Image:</td>
		<td class="admin_cell">
			<input id="image" name="image" type="file" value=""></input>
			<?php 
				if($item['image'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image']); 
					$fp = fopen(MENU_PATH.$item['image'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				}
				echo $ImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image'] != "") { ?>
					<input type="checkbox" name="delete_img" value="1"><strong>(Delete Image)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Hover Image:</td>
		<td class="admin_cell">
			<input id="image_hov" name="image_hov" type="file" value=""></input>
			<?php 
				if($item['image_hov'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image_hov']); 
					$fp = fopen(MENU_PATH.$item['image_hov'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				}
				echo $hovImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image_hov'] != "") { ?>
					<input type="checkbox" name="delete_hov" value="1"><strong>(Delete Hover Image)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Active Image:</td>
		<td class="admin_cell">
			<input id="image_act" name="image_act" type="file" value=""></input>
			<?php 
				if($item['image_act'] != "")
				{
					$size = getimagesize(MENU_PATH.$item['image_act']); 
					$fp = fopen(MENU_PATH.$item['image_act'], "rb");
					if ($size && $fp) 
					{
						echo $size[0]." x ";
						echo $size[1]." px ";
					}
				}
				echo $actImageStatus;
			?>
		</td>
		<td class="admin_cell_stat">
			<?php if($item['image_act'] != "") { ?>
					<input type="checkbox" name="delete_act" value="1"><strong>(Delete Active Image)</strong>
			<?php } ?>
		</td>
	</tr>
	<tr>
		<td class="admin_cell">Style CSS:</td>
		<td class="admin_cell">
			<input maxlength="250" name="style" type="text" value="<?php echo $item['style']; ?>" style="width:300">
			(Font Style, Size, Padding)
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<tr>
		<td class="admin_cell">Active:</td>
		<td class="admin_cell">
			<a href="?selected=<?php echo $item['id']; ?>&active=1"><img border="0" src="images/system/yes.png"></a>(Activate)&nbsp;&nbsp;
			<a href="?selected=<?php echo $item['id']; ?>&active=0"><img border="0" src="images/system/no.png"></a>(Deactivate)
		</td>
		<td class="admin_cell_stat"><?php if ($item['active'] == "1"){echo 'Activated <img border="0" src="images/system/yes.png">'; }else{echo 'Deactivated <img border="0" src="images/system/no.png">';} ?></td>
	</tr>
	<tr>
		<td></td>
		<td class="admin_cell" style="padding-top:10px; padding-bottom:10px;">
		<?php if($selected != ""){ ?>
			<input type="submit" value="Save Changes" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD;" />
			<input type="hidden" name="action" value="update_header">
		<?php } else {?>
			<input type="hidden" name="action" value="new_item">
			<input type="submit" value="Add new template" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" />
		<?php }?><?php echo "<br>".$error; ?>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<?php if ($item['id'] != "") {?>
	<tr>
		<td class="admin_cell">Selected Menu Display:</td>
		<td height="100">
			<?php echo buildMenu($item['template_id'], $item['type']); ?>
		</td>
		<td class="admin_cell_stat"></td>
	</tr>
	<?php }?>
</table>
</form>